using System;
using System.Collections.Generic;
using System.Web.UI;
using System.Web.UI.WebControls;
using OpenFlashChartLib;

namespace WebDemo
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            ofcTest.BuildChart();
        }

        protected void ofcTest_DrawChart(object sender, OpenFlashChartLib.DrawChartEventArgs e)
        {
            // Create graph object and initialize its display preferences
            Graph graph = new Graph();
            e.Graph = graph;
            graph.Title.Text = "";
            graph.Title.Style.Font.Size = new FontUnit(26, UnitType.Pixel);
            graph.XLabelStyle.Color = "#9933CC";
            graph.XLabelStyle.Size = 10;
            //graph.XLabelStyle.Values.Add(1);
            graph.YLegend.Text = "Votes";
            graph.YLegend.Size = 12;
            graph.YLegend.Color = "0x736AFF";
            graph.XLegend.Text = "Your question";
            graph.XLegend.Size = 14;
            graph.XLegend.Color = "0x736AFF";
            graph.YTicks.Size = 2;
            graph.Attributes.Add(new KeyValuePair(Tokens.BackgroundColor, "#FFFFFF"));

            // Create new data renderer
            DataRenderer<int> ret = new DataRenderer<int>();
            // Create a chart type wich you want to display
            // as GraphTypeRenderer
            PieGraphType pie = new PieGraphType();
            pie.Colors = new List<string>(new string[] { "E61C1C", "462CDE", "3F9735" });
            pie.Alpha = 60;
            ret.GraphTypeRenderer = pie;
            // Initialize XLables for the data set
            graph.XLabels.Values.Add("Answer 1");
            graph.XLabels.Values.Add("Answer 2");
            graph.XLabels.Values.Add("Answer 3");
            graph.XLabels.Values.Add("Answer 4");
            graph.XLabels.Values.Add("Answer 5");
            // Add Values to display
            ret.Values.Add(3);
            ret.Values.Add(3);
            ret.Values.Add(7);
            ret.Values.Add(12);
            ret.Values.Add(1);
            // Add data rendere to the Graph.Values collection
            graph.Values.Add(ret);
        }
    }
}
